package com.ddone.aop.annotation.advice;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author ddone
 * @date 2024/3/20-10:42
 */
@Component
@Aspect
@Slf4j
@Order(2)
public class DemoAround {
    @Around("com.ddone.aop.annotation.advice.TxAdvice.txPointCut()")
    public Object log(ProceedingJoinPoint joinPoint){
        Object[] args = joinPoint.getArgs();
        Object result = null;
        try {
             log.error("==========前置增强======");
             result = joinPoint.proceed(args);
            log.error("==========返回增强======");
        } catch (Throwable e) {
            e.printStackTrace();
            log.error("===========异常增强========");
        }finally {
            log.error("===========后置增强========");
        }

        return result;
    }
}
